import com.amazon.web.util.Tools;
import com.translate.TransApi;

import java.util.List;
import java.util.Map;

public class Main {

    // 在平台申请的APP_ID 详见 http://api.fanyi.baidu.com/api/trans/product/desktop?req=developer
    private static final String APP_ID = "20180715000185622";
    private static final String SECURITY_KEY = "RtGMlsmDQUDfmQ6Ddi5L";

    public static void main(String[] args) {
        TransApi api = new TransApi(APP_ID, SECURITY_KEY);

        String query = "货号:design-066;产品类别:棒球帽;适用性别:中性/男女均可;材质:棉质;风格:嘻哈;编织方法:平纹;加工方式:印花;流行元素:嘻哈;图案:花卉;适合季节:春季,秋季,冬季,夏季;适用送礼场合:开业典礼,员工福利,颁奖纪念,周年庆典,展销会,广告促销,节日,乔迁,婚庆,公关策划,生日,商务馈赠;产地:中国;檐形:平檐;帽顶款式:圆顶;帽檐款式:大檐;颜色:黑色;尺码:可调节;适用年龄段:成年;主要销售地区:东北亚,欧洲,非洲,东南亚,中东,南美,北美";


        System.out.println(api.getTransResult(query, "auto", "en"));

        Map<String,Object>    result = Tools.parserJson2Map(api.getTransResult(query, "auto", "en"));
        List<Map<String, Object>>  list = (List<Map<String, Object>>) result.get("trans_result");


        String enDes = list.get(0).get("dst").toString();

        String enDeses="";
        String[] ens =enDes.split(";");
        for(int i=0;i<ens.length;i++){
            enDeses+=ens[i]+"\n";
        }





        System.out.println(list.get(0).get("dst").toString());

        //p.setDescription(list.get(0).get("dst").toString());
    }

}
